#include "snailiotmonitoring.h"
#include "ui_snailiotmonitoring.h"

SnailIOTMonitoring::SnailIOTMonitoring(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::SnailIOTMonitoring)
{
    ui->setupUi(this);
    MonitoringTool::setStlyeSheet(":/imgs/btn.css");
    m_laout=new QStackedLayout;
    m_login=new MonitoringLogin(this);
    m_register=new MonitoringRegister(this);
    m_forgot=new MonitoringForgotPassword(this);
    m_laout->addWidget(m_login);
    m_laout->addWidget(m_register);
    m_laout->addWidget(m_forgot);
    this->setLayout(m_laout);

    connect(m_login,&MonitoringLogin::registerClick,this,[=](){
        m_laout->setCurrentIndex(1);
    });
    connect(m_login,&MonitoringLogin::forgotClick,this,[=](){
        m_laout->setCurrentIndex(2);
    });

    connect(m_register,&MonitoringRegister::registerClick,this,[=](){
        m_laout->setCurrentIndex(0);
    });
    connect(m_forgot,&MonitoringForgotPassword::forgotClick,this,[=](){
        m_laout->setCurrentIndex(0);
    });

    connect(m_login,&MonitoringLogin::loginClick,this,[=](QString username){
        m_main=new MonitoringMain(nullptr,username);
        m_main->show();
        this->close();
    });

    connect(m_register,&MonitoringRegister::backClick,this,[=](){
        m_laout->setCurrentIndex(0);
    });

    connect(m_forgot,&MonitoringForgotPassword::backClick,this,[=](){
        m_laout->setCurrentIndex(0);
    });
}

SnailIOTMonitoring::~SnailIOTMonitoring()
{
    delete ui;
}

